In this guide, we will create a payment using the ApteanPay GraphQL Playground.
Theses are the mandatory headers required for ApteanPay Merchant API (GraphQL).
{
"x-aptean-apim":"<<<your product specific apim key here>>>",
"x-aptean-tenant":"<<<your tenant id here>>>",
"x-aptean-tenant-secret": "<<<your tenant secret here>>>",
"idempotency-key":"<<<your idempotency key goes here>>>"
}
Please fill your respective values appropriately to use them.
To Create a Payment, perform the following steps.
Copy below text including the brackets.
mutation createPayment($input:CreatePaymentInput!){
createPayment(input:$input){
code
message
payment{
id
status
pendingReasonCode
failureReason
}
}
}
To create payment, copy below text including the brackets
Use the parameter "immediateCapture" as true to capture the payment immediately or false to only create a pre-auth
{
"input": {
"paymentMethodId": "<<<*payment method Id/token here-this is the value returned by Capture Credit Card or Bank SDK*>>>",
"amount":<<amount in cents>>,
"currency":"<<currency type here>>>",
"immediateCapture":true,
"riskMetadata":{
"address": {
"postalCode":"<<<postal code here>>>",
"country":"<<<country here>>>"
},
"phone": {
"countryCode":"<<<phone country here>>>",
"number":"<<<phone number here>>>"
},
"lineItems":[]
}
}
}
Once you see the response code as SUCCESS, you can get the Payment Id in the Id field of the response.
Sample SUCCESS Response:
{
"data": {
"createPayment": {
"code": "SUCCESS",
"message": "payment captured",
"payment": {
"id": "3dc14e58-7159-4e12-9c92-9603024c75f4",
"status": "COMPLETED"
}
}
}
}
| Error Message | Error Reason |
|---|---|
| Response not successful: Received status code 400 | "x-aptean-apim" entered is not a valid apteanpay apim key or "x-aptean-tenant-secret" entered is not correct |
| idempotency key has already been used, a unique key must be provided | idempotency-key given has already been used in past 24 hours. It should be unique. |
| idempotency key is required | unique "idempotency-key" must be passed in HTTP HEADERS |
| unable to create payment, payment method not found | paymentMethodId provided is not found in paymentMethods() |
| Expected payment amount does not match current amount | amount provided should match the payment request amount |
| Variable "$input" got invalid value "UbD" at "input.currency"; Value "UbD" does not exist in "CurrencyType" enum. Did you mean the enum value "USD" or "CAD"? | currency should be CAD / USD |